<template>
	<view class="fui-wrap">
		<fui-sticky>
			<view style="background-color: #fff;">
				<fui-segmented-control @click="sectionChange" :current="current" type="text" activeColor="#43afe8" :values="ordertype"></fui-segmented-control>
			</view>
		</fui-sticky>
		<fui-list>
			<fui-list-cell :padding="['22rpx', '32rpx', '8rpx', '32rpx']" v-for="(item,index) in list" :key="index" arrow @click="$navigateTo('index/orderdetail?out_trade_no='+item.out_trade_no)">
				<view class="itme">
					<view class="line">
						<view style="width: 40rpx;display: flex;align-items: center;justify-content: center;">
							<image :src="`${baseUrl}assets/img/miniapp/time.png`" style="width: 36rpx;" mode="widthFix"></image>
						</view>
						<fui-text :text="item.pay_time" color="#000000" :size="28" style="margin-left: 10rpx;"></fui-text>
					</view>
					<view class="line">
						<view style="width: 40rpx;display: flex;align-items: center;justify-content: center;">
							<image :src="`${baseUrl}assets/img/miniapp/dingwei.png`" style="width: 36rpx;" mode="widthFix"></image>
						</view>
						<fui-text style="margin-left:10rpx;" :text="item.parking_title" color="#000000" :size="28" block></fui-text>
					</view>
					<view class="line" v-if="item.plate_number">
						<view style="width: 40rpx;display: flex;align-items: center;justify-content: center;">
							<image :src="`${baseUrl}assets/img/miniapp/jiaoche.png`" style="width: 90rpx;" mode="widthFix"></image>
						</view>
						<fui-text style="margin-left:10rpx;" :text="item.plate_number" color="#000000" :size="28" block></fui-text>
					</view>
				</view>
				<fui-text style="position: absolute;right: 80rpx;" :text="'￥'+item.pay_price" color="#eb3b18" :size="32" block fontWeight="800"></fui-text>
			</fui-list-cell>
		</fui-list>
		<fui-empty v-if="list.length===0" :src="`${baseUrl}assets/img/miniapp/empty.png`" title="暂无数据!" :marginTop="200"></fui-empty>
	</view>
</template>

<script>
	import {methods,baseUrl} from '@/utils/core.js';
	import {formatDateTime,parseNumber} from '@/utils/util.js'
	export default {
		data() {
			return {
				baseUrl:baseUrl,
				ordertype:[
					{id:'parking',name:'停车订单'},
					{id:'parking_monthly',name:'月租订单'},
					{id:'parking_stored',name:'充值订单'}
				],
				current:0,
				list:[],
				page:1,
				endData:false
			}
		},
		onLoad(e) {
			this.getList();
		},
		onReachBottom() {
			this.getList();
		},
		onPullDownRefresh() {
			this.list=[];
			this.page=1;
			this.endData=false;
			this.getList(function(){
				uni.stopPullDownRefresh();
			});
		},
		methods: {
			...methods,
			parseNumber,
			sectionChange:function(e){
				this.current=e.index;
				this.list=[];
				this.page=1;
				this.endData=false;
				this.getList();
			},
			getList:function(callback=false){
				if(this.endData){
					this.$msg('已经到底了');
					return;
				}
				this.$get('orders/list',{
					page:this.page,
					type:this.ordertype[this.current].id
				},true).then(res=>{
					this.list=this.list.concat(res);
					this.page++;
					if(res.length<10){
						this.endData=true;
					}	
					if(callback){
						callback();
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
.fui-wrap{
	
}
.itme{
	height: 140rpx;
	display: flex;
	flex-direction: column;
	justify-content: space-around;
}
.line{
	display: flex;
	align-items: center;
	margin-bottom: 10rpx;
}
</style>